<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        color: red;
      }
    </style>
  </head>
  <body>
    <div class="box1">我是box1盒子</div>
    <div class="box2"></div>
  </body>
</html>
<script>
  // 一般操作和修改标签元素内容的方法：增删改查
  // 1-innerText属性
  // 2-innerHtml属性

  // 对象innerText增删改查
  // 1.1 查
  const box1 = document.querySelector(".box1");
  const box2 = document.querySelector(".box2");
  console.log(box1.innerText);
  // 1.2 改
  box1.innerText = "我是被修改的div内容";
  // 1.3 增
  box2.innerText = "我是被增加box2的div内容";
  // 1.4 删
  box1.innerText = "";

  //   特点
  // box1.innerText='<storng>box1内容</sorng>'  //加粗字体-----不解析标签
  box1.innerHTML = "<strong>innerHTML加粗内容</strong>";
</script>
